<?php
/**
 * 上传类
 * @author caoge
 * @version 2012-8-1
 */
class UploadAction extends Action{
	/**
	 * 上传图片
	 *
	 * @author caoge
	 * @version 2012-8-1
	 */
	public function uploadPic(){
		import("ORG.Net.UploadFile");
		import("ORG.Util.Image");//生成缩略图需要Image类
		$upload=new UploadFile();
		$upload->maxSize =4194304;//上传附件的大小限制,单位是字节,4M
		$upload->allowExts=array('jpg','jpeg','png','gif');//上传文件的允许的类型
		$upload->savePath ='Uploads/About/';//文件的保存目录,相对于项目入口文件
		$upload->saveRule='uniqid';//文件名称保存规则，函数名比如time.uniqid,可以是自定义函数的函数名
		$upload->thumb=true;
		$upload->thumbMaxWidth="150px";//缩略图的宽限制
		$upload->thumbMaxHeight="140px";
		if(!$upload->upload()){
			echo $upload->getErrorMsg();
		}else {
			$info=$upload->getUploadFileInfo();//getUploadFileInfo();返回一个二维数组
			$url = __ROOT__.'/'.$info[0]['savepath'].'thumb_'.$info[0]['savename'];
			echo $url;
		}
	}
}